﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Prowess.OIS.Component.Presenter.Interface;
using Prowess.OIS.Component.View.Interface;
using Prowess.OIS.Component.Model.Interface;
using Prowess.OIS.Component.ModelFactory;

namespace Prowess.Component.OIS.Presenter
{
    public class ConfigurationPresenter:IDatabaseConfigurationPresenter
    {
        private IConfiguration databaseConfigView;
        private IDatabaseConfigModel databaseConfigModel;

        public ConfigurationPresenter(IConfiguration databaseConfigView)
        {
            DatabaseConfigView = databaseConfigView;
            DatabaseConfigModel = DatabaseConfigModelFactory.GetDatabaseConfigModel();

        }
        public void TestConnection()
        {
            //throw new NotImplementedException();
            databaseConfigModel.ServerName = databaseConfigView.ServerName;
            databaseConfigModel.UserName = databaseConfigView.UserName;
            databaseConfigModel.PassWord = databaseConfigView.PassWord;
        }

        public void CreateDatabase()
        {
            //throw new NotImplementedException();
        }

        public IConfiguration DatabaseConfigView
        {
            get
            {
                return databaseConfigView;
            }
            set
            {
                databaseConfigView = value;
            }
        }


        public IDatabaseConfigModel DatabaseConfigModel
        {
            get
            {
                return databaseConfigModel;
            }
            set
            {
                databaseConfigModel = value;
            }
        }


        public void FillData()
        {
            databaseConfigView.ServerName = databaseConfigModel.ServerName;
            databaseConfigView.UserName = databaseConfigModel.UserName;
            databaseConfigView.PassWord = databaseConfigModel.PassWord;
            databaseConfigView.CreateDatabaseStatus = false;
        }
    }
}
